home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_VIEW.TXT < prev    next >
Encoding:
Text File  |  1993-01-21  |  20.7 KB  |  505 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:View class structure:
  5. Class View:
  6. ~~~~~~~~~~~
  7. this is standard I/O engine for your programs, which with exception of menu
  8. maintains the user interface. The data are displayed in two modes (Form and
  9. Browse). The databases can be viewed, edited, the information can be
  10. selected, with use of user defined indexes, filters and reports.
  11. All this functionality is network capable.
  12.  
  13.  
  14. Common use:
  15. ~~~~~~~~~~~
  16. The best is to study the examples DEMO1.prg, DEMO2.prg and DEMO3.prg.
  17.  
  18. The source code is in C_View.prg
  19.  
  20. !seealso: c_dbrows.ngo:DBrowse c_task.ngo:Task c_report.ngo:Report c_finfo.ngo:FInfo c_menu.ngo:Menu c_dbf.ngo:Dbf c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  21.  
  22. !short:~~~~~~~~~~~~~~~~~~~~~
  23. !short:create class View from DBrowse
  24. !short:  export:
  25. !short:  var ViewID    //0
  26. ^BView:ViewID^N: read-only: numeric
  27.   the unique object identification number for user defined indexes,filters
  28.   and reports in a database cIFR (OBasic1.dbf). All copies odf the object
  29.   have this number same to have the same menu.
  30.  
  31. !short:  var MenuID    //0
  32. ^BView:MenuID^N: private: numeric
  33.   The menu item number, which started it to active this menu item as a local
  34.   task menu. See the static function ViewSlipMenu() in C_View.prg.
  35.  
  36. !short:  var MenuNtxID //0
  37. ^BView:MenuNtxID^N: private: numeric
  38.   The number for index definition for supressing of a recursive index
  39.   definition.
  40.  
  41. !short:  var MenuFltID //0
  42. ^BView:MenuFltID^N: private: numeric
  43.   Number for filter definition, to supress the recursive filter definition
  44.   for this object.
  45.  
  46. !short:  var MenuRptID //0
  47. ^BView:MenuRptID^N: private: numeric
  48.   Number for report definition, to supress the recursive report definition
  49.   for this object.
  50.  
  51. !short:  var CanGoto   //true
  52. ^BView:CanGoto^N: private: logical
  53.   Enables / disables the goto command for this object, to select the record
  54.   must be the window active.
  55.  
  56. !short:  var Fields    //{}
  57. ^BView:Fields^N: private: array
  58.   All database fields to handle information in form of:
  59.   Fields:={}
  60.   AAdd( Fields, {cLongName,cShortName,cAlias,cField,cPicture,bWhen,bValid,;
  61.                  [nMemoRowSize,nMemoColSize,[bDoGet]} )
  62.   ...
  63. Where:
  64.   cLongName    - is the fieldname for Form mode
  65.   cShortName   - is the fieldname for Browse (Columun header)
  66.   cAlias       - is Alias() of fields database
  67.   cField       - is a fieldname
  68.   cPicture     - is a display mask
  69.   bWhen        - is a code block evaluated before entering this field, when
  70.                  returns false the field aditation is disabled. It can be
  71.                  used for result fields, or read only fields.
  72.   bValid       - is a code block to validate the entered data, when returns
  73.                  true the data is valid.
  74.   nMemoRowSize - window height for memo file (number of rows)
  75.   nMemoColSize - window width for memo field (number of columns)
  76.                  The memo field is edited in its own window of this sizes.
  77.   bDoGet       - is a code block to edit the field, if nothing is set the
  78.                  DoGet() method of DBrowse class is used.
  79.  
  80. !short:  var Action    //{}
  81. ^BView:Action^N: private: array
  82.   The array with a structure:
  83.   Action:={}
  84.   AAdd( Action, {nKey,bNewProc,bOldProc,cShortInfo} )
  85.   ...
  86.   Every object of this class can have its own hot key set with connected
  87.   functions. The element meaning is:
  88.   nKey       - is a InKey() code of a hot key
  89.   bNewProc   - code block to perform when a key is pressed
  90.   bOldProc   - this key previous assigned code block
  91.   cShortInfo - short help text to be displayed in dialog line about the
  92.                hot key
  93.  
  94. !short:  var Filter    //{{},{},{},{}}
  95. ^BView:Filter^N: private: array
  96.   This is object defined filter information. this instavar variable is
  97.   composed of theree paralel arrays:
  98.   first of them consists of filter names as menu items (character)
  99.   second of them consists of the filter expression (Character)
  100.   third is the array of logical values defining if the user is enabled
  101.         to modify the filter definition. The filter definitions created
  102.         in a program are unchangeable but there is a possiblity to change
  103.         the user run time defined filters.
  104.  
  105. !short:  var Report    //{{},{},{}}
  106. ^BView:Report^N: private: array
  107.   This is current object report information. This instvar variable consists
  108.   off three paralel arrays:
  109.   first of them consists of report names as menu items (character)
  110.   second of them is the report definition
  111.    array={cTop,aFields,cBottom,lOnlyTotals}
  112.   third is the array of logical values defining if the user is enabled
  113.         to modify the report definition. The report definitions created
  114.         in a program are unchangeable but there is a possiblity to change
  115.         the user run time defined reports.
  116.  
  117.   cTop is a report header, the lines are separated by semicolon (;)
  118.   aFields={cShortName,cField,cPicture,lTotal,cSubtotal} where:
  119.     cShortName report column header
  120.     cField database field to print
  121.     cPicture output mask for cField
  122.     lTotal sets the field to be totaled
  123.     cSubTotal sets the field to subtotal according to
  124.   cBottom final (Bottom) report text, lines of which are semicolon (;)
  125.     separated.
  126.   lOnlyTotals default is false, i.e. standart (full) report.
  127.     is is true, then report will be contain only subtotals and totals.
  128.  
  129. !short:  method New=ViewNew              //o:New() --> self --> self
  130. ^BView:New()^N: public: return self
  131.   The object is filled with default values.
  132.  
  133. !short:  method Copy=ViewCopy            //o:Copy() --> copy_of_current_view_object
  134. ^BView:Copy()^N:public: return copy_of_self
  135.   Returns a current copy of this class object.
  136.  
  137. !short:  method CreateObj=ViewCreateObj  //o:CreateObj() --> new_object_of_this_class
  138. ^BView:CreateObj()^N:public: return new_self_of_this_class
  139.    Returns new object of this class.
  140.  
  141. !short:  method Init=ViewInit            //o:Init() --> true
  142. ^BView:Init()^N: public: return true
  143.   Object internal init.
  144.  
  145. !short:  method Select=ViewSelect        //o:Select(cAlias) --> true
  146. ^BView:Select(cAlias)^N: public: return true
  147.   Select of active database, when object is active.
  148.  
  149. !short:  method DefWindow=ViewDefWindow  //o:DefWindow(Name,R,C,Rs,Cs,Clr) --> true
  150. ^BView:DefWindow()^N:public: return true
  151.   Object window size (fill of instavar variables)
  152.  
  153. !short:  method AddBlock=ViewAddBlock    //o:AddBlock(cLongNm,cShortNm,cVarNm,bBlock,bDoGet,cPict,bWhen,bValid) --> true
  154. ^BView:AddBlock(LongName,ShortName,VarName,Block,DoGet,Pict,When,Valid)^N:
  155.   public: return true
  156.   Next column appended to the object by a code block. When editing it is not
  157.   tested the record virtuality, the records with je RecNo()>LastRec() can be
  158.   edited.
  159.  
  160.   Parameter description:
  161.   ~~~~~~~~~~~~~~~~~~~~~~
  162.   ^ULongName^N: character: default is ShortName
  163.    Column name used in mode of Form(ular).
  164.  
  165.   ^UShortName^N: character: default is ""
  166.    Column name used in mode of Browse.
  167.  
  168.   ^UVarName^N: character: default is ShortName
  169.    Edited variable name, or database fieldname stored as an information to clipper
  170.    Get object, created in this method and stored to DoGet array. The clipper get object
  171.    should know the edited variable name.
  172.  
  173.   ^UBlock^N: code_block: no default
  174.    Get/set code block created by the functions FieldBlock(), FieldWBlock(), MemVarBlock() or
  175.    own code piece.
  176.  
  177.   ^UDoGet^N: code_block: default is virtual_method_Browse:DoGet()
  178.    Code block to edit the column respective variable with use of the Get object.
  179.  
  180.   ^UPicture^N: character: default is ""
  181.    The column picture display mask.
  182.  
  183.   ^UWhen^N: code_block: default is {||true}
  184.    Code block to be evaluated before the entering the column editation.
  185.    If false the editation is disabled. The result fields or read-only
  186.    fields can be produced this way.
  187.  
  188.   ^UValid^N: code_block: default is {||true}
  189.    Code block to validate the entered data, if the result is true the data
  190.    is valid, if false the entered data must be reedited.
  191.  
  192. !short:  method AddMemo=ViewAddMemo      //o:AddMemo(cLongNm,cShortNm,cField,bWhen,bValid,nRowSize,nColSize) --> true
  193. ^BView:AddMemo(cLongName,cShortName,cField,bWhen,bValid,nRowSize,nColSize)^N:
  194.   public: return true
  195.   The object is appended with next column defined as memo field.
  196.   The virtuality is tested, it is not allowed to edit the fields
  197.   with RecNo()>LastRec().
  198.  
  199.   Parameter description:
  200.   ~~~~~~~~~~~~~~~~~~~~~~
  201.   ^ULongName^N: character: default is ShortName
  202.    Column name used in mode of  Form(ular).
  203.  
  204.   ^UShortName^N: character: default is ""
  205.    Column name used in mode of Browse.
  206.  
  207.   ^UcField^N: character: no default
  208.    Full memo field name (field->name),
  209.    if no prefix used, it is taken from instvar variable View:Alias.
  210.  
  211.   ^UWhen^N: code_block: default is {||true}
  212.    Code block to be evaluated before the entering the column editation.
  213.    If false the editation is disabled. The result fields or read-only fields
  214.    can be produced this way.
  215.  
  216.   ^UValid^N: code_block: default is {||true}
  217.    Code block to validate the entered data, if the result is true the data
  218.    is valid, if false the entered data must be reedited.
  219.  
  220.   ^UnRowSize^N: numeric: default is MaxRow()/3
  221.    The MemoEdit window height as row number.
  222.  
  223.   ^UnColSize^N: numeric: default is MaxCol()/2
  224.    The MemoEdit window width as column number.
  225.  
  226. !short:  method AddField=ViewAddField    //o:AddField(cLongNm,cShortNm,cField,cPict,bWhen,bValid) --> true
  227. ^BView:AddField(LongName,ShortName,Field,Picture,When,Valid)^N:
  228.   public: return true
  229.   The object is appended with next column defined as database field.
  230.  
  231.   Parameter description:
  232.   ~~~~~~~~~~~~~~~~~~~~~~
  233.   ^ULongName^N: character: default is ShortName
  234.    Column name used in mode of  Form(ular).
  235.  
  236.   ^UShortName^N: character: default is ""
  237.    Column name used in mode of  Browse.
  238.  
  239.   ^UcField^N: character: no default.
  240.    Full memo field name (field->name),
  241.    if no prefix used, it is taken from instvar variable View:Alias.
  242.  
  243.   ^UcPicture^N: character: default is ""
  244.    The column picture display mask.
  245.  
  246.   ^UWhen^N: code_block: default is {||true}
  247.    Code block to be evaluated before the entering the column editation.
  248.    If false the editation is disabled. The result fields or read-only
  249.    fields can be produced this way.
  250.  
  251.   ^UValid^N: code_block: default is {||true}
  252.    Code block to validate the entered data, if the result is true the data
  253.    is valid, if false the entered data must be reedited.
  254.  
  255.   ^UnRowSize^N: numeric: default is MaxRow()/3
  256.    The MemoEdit window height as row number.
  257.  
  258.   ^UnColSize^N: numeric: default is MaxCol()/2
  259.    The MemoEdit window width as column number.
  260.  
  261. !short:  method AddFilter=ViewAddFilter  //o:AddFilter(cName,cExpr,lMark) --> true
  262. ^BView:AddFilter(cName,cExpr)^N: public: return true
  263.   Programmer defined filter.
  264.  
  265.   Parameter description:
  266.   ~~~~~~~~~~~~~~~~~~~~~~
  267.   ^UcName^N: character: no default.
  268.    Filter name to display as menu item name. The prefix ~ sets the hilited
  269.    character to be accelerator for menu item selection speeding up.
  270.  
  271.   ^UcExpr^N: character: no default.
  272.    The filter expression
  273.  
  274. !short:  method AddRAll=ViewAddRAll      //o:AddRAll(cName,cTop,aFields,cBottom,lOnlyTotals) --> true
  275. ^BView:AddRAll(cName,cTop,aFields,cBottom,lOnlyTotals)^N: public: return true
  276.   One command report definition append.
  277.  
  278.   Parameter description:
  279.   ~~~~~~~~~~~~~~~~~~~~~~
  280.   ^UcName^N is report name to diplay as a menu item, the prefix ~
  281.   sets the hilited character to be the accelerator for
  282.   menu item selection speeding up.
  283.  
  284.   ^UcTop^N is report header, each row is semicolon separated.
  285.  
  286.   ^UaFields^N={cShortName,cField,cPicture,lTotal,cSubtotal} kde:
  287.    cShortName is report column header
  288.    cField is database field to print
  289.    cPicture is cField output picture mask
  290.    lTotal sets the field to be totaled
  291.    cSubTotal sets the field to total according to
  292.  
  293.   ^UcBottom^N is final report text, each line to be semicolon separated.
  294.  
  295. !short:  method AddReport=ViewAddReport  //o:AddReport(cName,lOnlyTotals) --> true
  296. ^BView:AddReport(cName,lOnlyTotals)^N: public: return true
  297.    Begin of programmer defined report.
  298.  
  299.   Parameter description:
  300.   ~~~~~~~~~~~~~~~~~~~~~~
  301.   ^UcName^N is report header name, to be displayed as menu item, the
  302.    prefix ~ is to set the hilited character to be the accelerator key,
  303.    for speeding up the menu selection.
  304.  
  305. !short:  method AddRTop=ViewAddRTop      //o:AddRTop(cTop) --> true
  306. ^BView:AddRTop(cTop)^N: public: return true
  307.   Continues in programmer defining of a report.
  308.   cTop report header, the lines are semicolon separated
  309.  
  310. !short:  method AddRField=ViewAddRField  //o:AddRField(cTitle,aField,cPict,lTot,cSubT) --> true
  311. ^BView:AddRField(cTitle,cField,cPicture,lTotal,cSubTotal)^N:
  312.   public: return true
  313.   Continues in programmer defining of a report.
  314.   cTitle: character: default is cField, the report column header
  315.   cField: character: no default.
  316.    contain full name of database field that must be printed (alias->filed)
  317.    if isn't full name (only field part exist) then alias will be instvar
  318.    variable View:Alias.
  319.   cPicture: character: no default.
  320.    Output picture mask for cField.
  321.   lTotal: logical: default is false, sets the field to be totaled
  322.   cSubTotal: character: default is "", sets the field to make subtotal
  323.    according to.
  324.  
  325. !short:  method AddRBottom=ViewAddRBotto //o:AddRBottom(cBottom) --> true
  326. ^BView:AddRBottom(cBottom)^N: public: return true                                  
  327.   Continues in programmer report definition.
  328.   cBottom is final report text, each line to be semicolon separated.
  329.  
  330. !short:  method AddAction=ViewAddAction  //o:AddAction(nKey,bProcedure,cInfo) --> true
  331. ^BView:AddAction(nKey,bFunction,cShortInfo)^N: public: return true
  332.   Own hot keys definition for this object, and their assigned functions
  333.   definition, for performing these functions with a single keypress.
  334.  
  335.   Parameter description:
  336.   ~~~~~~~~~~~~~~~~~~~~~~
  337.   ^UnKey^N: numeric: no default.
  338.    It is InKey() code of a "hot key"
  339.  
  340.   ^UbFunction^N: code_block: no default.
  341.    Code block to be performed after a hot key is pressed.
  342.  
  343.   ^UcShortInfo^N: character: default is ""
  344.    It is short help text, to be apended to a dialog line, to inform
  345.    about the hot key.
  346.  
  347. !short:  method View=ViewView            //o:View(ID,Name,R,C,Rs,Cs,Clr,Shd) --> true
  348. ^BView:View(ID,Name,R,C,Rs,Cs,Clr,Shadow)^N: public: return true
  349.   Copy of an object is created, default initialised as a view object,
  350.   painted to the screen and started as the task.
  351.  
  352.   Parameter description:
  353.   ~~~~~~~~~~~~~~~~~~~~~~
  354.   ^UID^N: numeric no default.
  355.    It is a menu item number to start this method, for compatibility of menu system.
  356.  
  357.   ^UName^N: text or code block: default is {||""}, no title.
  358.    Text or code block as window title.
  359.  
  360.   ^UR^N: numeric: default is 3.
  361.    Top window border.
  362.  
  363.   ^UC^N: numeric: default is 4.
  364.    Left window border.
  365.  
  366.   ^URs^N: numeric: default is MaxRow()-7.
  367.    Window height in number of rows to fit in.
  368.  
  369.   ^UCs^N: numeric: default is MaxCol()-9.
  370.    Window width in number of columns to fit in.
  371.  
  372.   ^UClr^N: character: default is m->Color:Edit.
  373.    Window colors.
  374.  
  375.   ^UShadow^N: logical: default is true for color monitor, false for monochrom.
  376.    If true, the shadow will be painted.
  377.  
  378. !short:  method Edit=ViewEdit            //o:Edit(ID,Name,R,C,Rs,Cs,Clr,Shd) --> true
  379. ^BView:Edit(ID,Name,R,C,Rs,Cs,Clr,Shadow)^N: public: return true
  380.   The same as View:View, but instead of view object is edit object created.
  381.  
  382. !short:  method ViewEdit=ViewViewEdit    //o:ViewEdit(ID,Name,R,C,Rs,Cs,Clr,Shd) --> true
  383. ^BView:ViewEdit(ID,Name,R,C,Rs,Cs,Clr,Shadow)^N: public: return true
  384.   It is the initialising method of an new edit or view object. Use it
  385.   to make your own object copies.
  386.  
  387.   Parameter description:
  388.   ~~~~~~~~~~~~~~~~~~~~~~
  389.   the same as in View:View
  390.  
  391. !short:  method Goto=ViewGoto            //o:Goto(ID,Name,R,C,Rs,Cs,Clr,Shd) --> true
  392. ^BView:Goto(ID,Name,R,C,Rs,Cs,Clr,Shadow)^N: public: return true
  393.   Jumps to user entered current database record number.
  394.  
  395.   Parameter description:
  396.   ~~~~~~~~~~~~~~~~~~~~~~
  397.   the same as in View:View
  398.  
  399. !short:  method Locate=ViewLocate        //o:Locate(ID,Name,R,C,Rs,Cs,Clr,Shd) --> true
  400. ^BView:Locate^N: public: return true
  401.   Searches from current record to the end of file in selected field
  402.   for a substring.
  403.  
  404. !short:  method PreGoto=ViewPreGoto      //o:PreGoto(Menu,MdId) --> true
  405. ^BView:PreGoto(Menu,MdId)^N: public: return true
  406.   Prevalid (when) function called from a menu to validate the atempt
  407.   of method View:Goto() activation.
  408.  
  409.   Parameter description:
  410.   ~~~~~~~~~~~~~~~~~~~~~~
  411.   ^UMenu^N: object_of_Menu: no default.
  412.    Menu which requests the validity test and sends self to the method.
  413.  
  414.   ^UMdId^N: numeric: no default.
  415.    The MenuDataID number for setting the data structure of Menu object to
  416.    prevalidate.
  417.  
  418. !short:  method PostGoto=ViewPostGoto    //o:PostGoto(Menu,MdId) --> true
  419. ^BView:PostGoto(Menu,MdId)^N: public: return true
  420.   The postvalid function to be prformed after the finish of View:GoTo()
  421.   method, to enable (if disabled by PreGoto() method) the method View:GoTo()
  422.   activation.
  423.  
  424.   Parameter description:
  425.   ~~~~~~~~~~~~~~~~~~~~~~
  426.   ^UMenu^N: object_of_Menu: no default.
  427.    Menu that requested the validation sends self to the method.
  428.  
  429.   ^UMdId^N: numeric: no default.
  430.    It is the MenuDataID number to set the Menu object data structure
  431.    that needs the postvalidation.
  432.  
  433. !short:  method SetIndex=ViewSetIndex    //o:SetIndex(ID,R,C,CurSize,Clr,Shd) --> true
  434. ^BView:SetIndex(ID,R,C,CurSize,Clr,Shadow)^N: public: return true
  435.   Selects the programmer defined or user runtime defined index, to be active.
  436.  
  437.   Parameter description:
  438.   ~~~~~~~~~~~~~~~~~~~~~~
  439.   the same as in View:View
  440.  
  441. !short:  method SetFilter=ViewSetFilter  //o:SetFilter(ID,R,C,CurSize,Clr,Shd) --> true
  442. ^BView:SetFilter(ID,R,C,CurSize,Clr,Shadow)^N: public: return true
  443.   Selects the programmer defined or user runtime defined filter, to be active.
  444.  
  445.   Parameter description:
  446.   ~~~~~~~~~~~~~~~~~~~~~~
  447.   the same as in View:View
  448.  
  449. !short:  method SetReport=ViewSetReport  //o:SetReport(ID,WinNam,R,C,CurSize,Clr,Shd) --> true
  450. ^BView:SetReport(ID,WinName,R,C,CurSize,Clr,Shadow)^N: public: return true
  451.   Selects the programmer defined or user runtime defined report, to be active.
  452.   The report file is generated, it can be viewed and printed to produce
  453.   a report.
  454.  
  455.   Parameter description:
  456.   ~~~~~~~~~~~~~~~~~~~~~~
  457.   the same as in View:View
  458.  
  459. !short:  method ModIndex=ViewModIndex    //o:ModIndex(ID,WinNam,R,C,CurSize,Clr,Shd) --> true
  460. ^BView:ModIndex(ID,WinName,R,C,CurSize,Clr,Shadow)^N: public: return true
  461.   User is enabled to create its own index and append it to other ones.
  462.   He is enabled to modify himself created indexes and to delete them.
  463.   The new index creation is performed in a child process, activated
  464.   from a main menu or from a class view local menu. This child process,
  465.   is assigned the indenpendent help process to, about how to create a new
  466.   index. When finishing the child process, this process is finished too.
  467.  
  468.   Parameter description:
  469.   ~~~~~~~~~~~~~~~~~~~~~~
  470.   the same as in View:View
  471.  
  472. !short:  method ModFilter=ViewModFilter  //o:ModFilter(ID,WinNam,R,C,CurSize,Clr,Shd) --> true
  473. ^BView:ModFilter(ID,WinName,R,C,CurSize,Clr,Shadow)^N: public: return true
  474.   The same as in ModIndex but handles the filter definitions.
  475.  
  476. !short:  method ModReport=ViewModReport  //o:ModReport(ID,WinNam,R,C,CurSize,Clr,Shd) --> true
  477. ^BView:ModReport(ID,WinName,R,C,CurSize,Clr,Shadow)^N: public: return true
  478.   The same as in ModIndex but handles the report definitions and the help
  479.   process is not created.
  480.  
  481. !short:  method VProcess=ViewVProcess    //o:VProcess() --> true
  482. ^BView:VProcess()^N: private: return true
  483.   The parent VProcess() definition is apended with a activation
  484.   and deactivation of object hot keys.
  485.  
  486. !short:  method Done=ViewDone            //o:Done(lRePaint) --> true
  487. ^BView:Done(lRePaint)^N: private: return true
  488.   The parent Done() method is apended with current view objects stack top
  489.   object erase. Pay attention that this is not class task stack.
  490.   The view class maintains its own stack of view objects for index,
  491.   filter and report enabling, disabling and modifiing maintenance.
  492.  
  493. !short:  private:
  494. !short:  method EndViewEdit=ViewEndViewEdit    //o:EndViewEdit() --> true
  495. ^BView:EndViewEdit^N: public: return true
  496.   The necessary object copy update is performed before activating of the
  497.   VProcess(). The multiple opening of the same window must have the same
  498.   index, filter and report definitions for all copies of the same object.
  499.   Therefore the created object copy must be updated to have the definition
  500.   storing fields not to be a copies (by AClone()), but only a pointers
  501.   assigned to the same fields for all copies of an object.
  502.  
  503. !short:  endclass
  504.  
  505.